package com.yvon.grpc.api;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.30.2)",
    comments = "Source: ip_name.proto")
public final class NameServersGrpc {

  private NameServersGrpc() {}

  public static final String SERVICE_NAME = "NameServers";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<com.yvon.grpc.api.Name,
      com.yvon.grpc.api.Ip> getGetIpByNameMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "getIpByName",
      requestType = com.yvon.grpc.api.Name.class,
      responseType = com.yvon.grpc.api.Ip.class,
      methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
  public static io.grpc.MethodDescriptor<com.yvon.grpc.api.Name,
      com.yvon.grpc.api.Ip> getGetIpByNameMethod() {
    io.grpc.MethodDescriptor<com.yvon.grpc.api.Name, com.yvon.grpc.api.Ip> getGetIpByNameMethod;
    if ((getGetIpByNameMethod = NameServersGrpc.getGetIpByNameMethod) == null) {
      synchronized (NameServersGrpc.class) {
        if ((getGetIpByNameMethod = NameServersGrpc.getGetIpByNameMethod) == null) {
          NameServersGrpc.getGetIpByNameMethod = getGetIpByNameMethod =
              io.grpc.MethodDescriptor.<com.yvon.grpc.api.Name, com.yvon.grpc.api.Ip>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "getIpByName"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  com.yvon.grpc.api.Name.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  com.yvon.grpc.api.Ip.getDefaultInstance()))
              .setSchemaDescriptor(new NameServersMethodDescriptorSupplier("getIpByName"))
              .build();
        }
      }
    }
    return getGetIpByNameMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static NameServersStub newStub(io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<NameServersStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<NameServersStub>() {
        @java.lang.Override
        public NameServersStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new NameServersStub(channel, callOptions);
        }
      };
    return NameServersStub.newStub(factory, channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static NameServersBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<NameServersBlockingStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<NameServersBlockingStub>() {
        @java.lang.Override
        public NameServersBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new NameServersBlockingStub(channel, callOptions);
        }
      };
    return NameServersBlockingStub.newStub(factory, channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static NameServersFutureStub newFutureStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<NameServersFutureStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<NameServersFutureStub>() {
        @java.lang.Override
        public NameServersFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new NameServersFutureStub(channel, callOptions);
        }
      };
    return NameServersFutureStub.newStub(factory, channel);
  }

  /**
   */
  public static abstract class NameServersImplBase implements io.grpc.BindableService {

    /**
     */
    public void getIpByName(com.yvon.grpc.api.Name request,
        io.grpc.stub.StreamObserver<com.yvon.grpc.api.Ip> responseObserver) {
      asyncUnimplementedUnaryCall(getGetIpByNameMethod(), responseObserver);
    }

    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getGetIpByNameMethod(),
            asyncServerStreamingCall(
              new MethodHandlers<
                com.yvon.grpc.api.Name,
                com.yvon.grpc.api.Ip>(
                  this, METHODID_GET_IP_BY_NAME)))
          .build();
    }
  }

  /**
   */
  public static final class NameServersStub extends io.grpc.stub.AbstractAsyncStub<NameServersStub> {
    private NameServersStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected NameServersStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new NameServersStub(channel, callOptions);
    }

    /**
     */
    public void getIpByName(com.yvon.grpc.api.Name request,
        io.grpc.stub.StreamObserver<com.yvon.grpc.api.Ip> responseObserver) {
      asyncServerStreamingCall(
          getChannel().newCall(getGetIpByNameMethod(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class NameServersBlockingStub extends io.grpc.stub.AbstractBlockingStub<NameServersBlockingStub> {
    private NameServersBlockingStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected NameServersBlockingStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new NameServersBlockingStub(channel, callOptions);
    }

    /**
     */
    public java.util.Iterator<com.yvon.grpc.api.Ip> getIpByName(
        com.yvon.grpc.api.Name request) {
      return blockingServerStreamingCall(
          getChannel(), getGetIpByNameMethod(), getCallOptions(), request);
    }
  }

  /**
   */
  public static final class NameServersFutureStub extends io.grpc.stub.AbstractFutureStub<NameServersFutureStub> {
    private NameServersFutureStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected NameServersFutureStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new NameServersFutureStub(channel, callOptions);
    }
  }

  private static final int METHODID_GET_IP_BY_NAME = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final NameServersImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(NameServersImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_GET_IP_BY_NAME:
          serviceImpl.getIpByName((com.yvon.grpc.api.Name) request,
              (io.grpc.stub.StreamObserver<com.yvon.grpc.api.Ip>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class NameServersBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    NameServersBaseDescriptorSupplier() {}

    @java.lang.Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return com.yvon.grpc.api.NameProto.getDescriptor();
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("NameServers");
    }
  }

  private static final class NameServersFileDescriptorSupplier
      extends NameServersBaseDescriptorSupplier {
    NameServersFileDescriptorSupplier() {}
  }

  private static final class NameServersMethodDescriptorSupplier
      extends NameServersBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    NameServersMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (NameServersGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new NameServersFileDescriptorSupplier())
              .addMethod(getGetIpByNameMethod())
              .build();
        }
      }
    }
    return result;
  }
}
